/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 */

package opensocial.apps.friendforsale.service;

import java.util.List;

import opensocial.apps.friendforsale.model.Activity;
import opensocial.apps.friendforsale.model.ActivityType;
import opensocial.apps.friendforsale.model.Player;
import opensocial.apps.friendforsale.model.PlayerPK;

/**
 * persistence interface
 * 
 * @author Sirius
 * 
 */
public interface FriendPersist {

  /**
   * persist player data
   * @param data Player object to be persist
   */
  public void save(Player data);

  /**
   * load specific Player data use primary key
   * @param id instance of PlayerPK
   * @return Player
   */
  public Player load(PlayerPK pk);
  
  /**
   * load specific Player data use id and container
   * @param container
   * @param id
   * @return
   */
  public Player load(String container,String id);

  /**
   * persist ActionItem
   * @param ai
   */
  public void save(Activity ai);

  /**
   * remove Player from persistence
   * @param player
   */
  public void remove(Player player);
  
  /**
   * remove activity from persistence
   * @param activity
   */
  public void remove(Activity activity);
  
  /**
   * load all activity of player include active and passive activity
   * @param player
   * @return List<Activity>
   */
  public List<Activity> loadActivity(Player player);

  /**
   * get the last activity viewer do to target
   * 
   * @param viewer
   * @param target
   * @param type
   * @return
   */
  public Activity getLastActivity(Player viewer, Player target,
      ActivityType type);

  /**
   * load all slaves of player
   * 
   * @param player
   * @return
   */
  public List<Player> loadSlaves(Player player);

  /**
   * 
   * @param container
   * @param ids
   * @return
   */
  public List<Player> loadFriends(String container, String ids);

  /**
   * 
   * @param container
   * @param in
   * @param sort
   * @param max
   * @return
   */
  public List<Player> top(String container, String in, String sort, int max);

}
